﻿<UserControl x:Class="VMWareLabWorkflowsDataContracts.VMWareLabDetailsDialogControls.DeploymentDetailsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="500" Background="LightGray">
    <Grid Margin="12,12,12,12" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <CheckBox Grid.Row="0" Content="Deploy the build" Height="16" HorizontalAlignment="Left" Name="cbDeploy" VerticalAlignment="Top" IsChecked="{Binding Path=DeploymentDetails.DeploymentNeeded}"/>
        <TextBlock Grid.Row="1" Width="400" HorizontalAlignment="Left" TextWrapping="Wrap" Margin="0,0,0,10" Text="The deployment scripts and optional arguments will be run in the order that is shown in the following list.  Each script is of the format BuildAgentName PathToExecutable Arguments. Example: AgentName cmd.exe /c copy $(BuildLocation)\install.exe C:\installer"></TextBlock>

        <Grid Grid.Row="2" Margin="0,0,0,3" IsEnabled="{Binding ElementName=cbDeploy, Path=IsChecked}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <DataGrid
            Width="400"
            Height="150"
            Margin="0,0,2,0"
            Grid.Column="0"
           x:Name="dgScripts"
            IsEnabled="{Binding ElementName=cbDeploy, Path=IsChecked}"
           ItemsSource="{Binding DeploymentScripts}"
                SelectedItem="{Binding Path=SelectedDeploymentScript}"
           AutoGenerateColumns="False"
           CanUserAddRows="True"
           CanUserDeleteRows="True"
           CanUserSortColumns="True"
           CanUserReorderColumns="True"
           AlternatingRowBackground="WhiteSmoke"
           RowHeaderWidth="16" 
            HorizontalAlignment="Left"
           VerticalAlignment="Top"
                Validation.ErrorTemplate="{x:Null}"
                GridLinesVisibility="None">
                <DataGrid.Columns>
                    <DataGridComboBoxColumn
                        Header="Build Agent Name" 
                        CanUserReorder="True"
                        IsReadOnly="False"
                        CanUserSort="False"
                        SelectedItemBinding="{Binding BuildAgentName}"
                            Width="Auto">

                        <DataGridComboBoxColumn.ElementStyle>
                            <Style TargetType="{x:Type ComboBox}">
                                <Setter Property="ItemsSource" Value="{Binding Path=DataContext.BuildAgents, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
                            </Style>
                        </DataGridComboBoxColumn.ElementStyle>
                        <DataGridComboBoxColumn.EditingElementStyle>
                            <Style TargetType="{x:Type ComboBox}">
                                <Setter Property="ItemsSource" Value="{Binding Path=DataContext.BuildAgents, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
                            </Style>
                        </DataGridComboBoxColumn.EditingElementStyle>
                    </DataGridComboBoxColumn>
                    
                    <DataGridTextColumn
                        Header="Path to Executable" 
                        Binding="{Binding PathToExecutable}"
                        CanUserReorder="True"
                        IsReadOnly="False"
                        CanUserSort="False"
                            Width="Auto"/>
                    <DataGridTextColumn
                       Header="Arguments" 
                       Binding="{Binding Arguments}"
                       CanUserReorder="True"
                       IsReadOnly="False"
                       CanUserSort="False"
                            Width="*"/>
                </DataGrid.Columns>
            </DataGrid>

            <StackPanel Grid.Column="1">
                <Button Margin="0,0,0,2" Content="↑" FontSize="18" Height="25" HorizontalAlignment="Left" Name="btnUp" VerticalAlignment="Top" Width="25" FontStyle="Normal" Command="{Binding MoveScriptUp}" />
                <Button Content="↓" Height="25" FontSize="18" HorizontalAlignment="Left" Name="btnDown" VerticalAlignment="Top" Width="25" Command="{Binding MoveScriptDown}"/>
            </StackPanel>

        </Grid>
        <Grid Grid.Row="3" Margin="0,0,0,20" IsEnabled="{Binding ElementName=cbDeploy, Path=IsChecked}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="80"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" Content="Add" Height="23" HorizontalAlignment="Left" Name="btnAdd" VerticalAlignment="Top" Width="75" Command="{Binding AddScript}"/>
            <Button Grid.Column="1" Content="Delete" Height="23" HorizontalAlignment="Left" Name="btnDelete" VerticalAlignment="Top" Width="75" Command="{Binding RemoveScript}"/>
        </Grid>

        <CheckBox Grid.Row="4" Margin="0,0,0,7" Content="Take a snapshot of the environment after deploying the build" 
                  Height="16" HorizontalAlignment="Left" 
                  Name="cbSnapshot" 
                  VerticalAlignment="Top" 
                  IsEnabled="{Binding ElementName=cbDeploy, Path=IsChecked}"
                  IsChecked="{Binding Path=DeploymentDetails.TakePostDeploymentSnapshot}"/>

        <Grid Grid.Row="5" IsEnabled="{Binding ElementName=cbDeploy, Path=IsChecked}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Column="0" Height="23" Margin="0,3,0,0" HorizontalAlignment="Left" Name="textBlock1" Text="Snapshot name:" VerticalAlignment="Top" />
            <TextBox Grid.Column="1" Height="23" HorizontalAlignment="Left"  Name="tbSnapshotName" 
                     VerticalAlignment="Top" Width="300" 
                     IsEnabled="{Binding ElementName=cbSnapshot, Path=IsChecked}"
                     Text="{Binding Path=DeploymentDetails.PostDeploymentSnapshotName}"/>
        </Grid>
    </Grid>
</UserControl>
